# _*_ coding : utf-8 _*_
# @Time : 2023/3/14 0014 16:16
# @Author : 菜鸟王小二
# @File : 1_urllib使用
# @Project : python爬虫

import urllib.request

# 模拟浏览器打开百度，获取页面数据
# 一个类型HTTPResponse 6个方法read() readline() readlines() getcode() geturl() getheaders()
def open_baidu(url):
    response = urllib.request.urlopen(url)
    text = response.read().decode('utf-8')
    # text = response.getheaders()
    return text

if __name__ == '__main__':
    result = open_baidu('https://www.baidu.com')
    print(result)